classdef Salinity < Processor
  % Class for Salinity
  % Derived from Processor
  % Constructor signature: S = Salinity(data, conn, P, T, C), 
  %     all args. optional
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: N/A
  
    properties
      % inherited from Processor
%         inData;
%         castDT;
%         scanRate;
%         ParamID;
%         ParamDesc;
%         SBEprec;
%         EquipID;
        DBdata;
        outData;
    end
    
    methods
        function S = Salinity(data, conn, P, T, C) % Constructor
            global mSB
            
            if nargin < 1, data = []; end
            S = S@Processor(data);
            
            if nargin < 2, conn = []; end
            if ~isempty(conn), S.getDBdata(conn, 'S'); end

            if nargin < 3, P = []; 
            elseif mSB, P = round2(P, 1e-3);
            end
            
            if nargin < 4, T = []; 
            elseif mSB, T = S.DBdata.SIPTS682ITS90Ratio * round2(T, 1e-4); % ITS90 => IPTS68
            else T = S.DBdata.SIPTS682ITS90Ratio * T;
            end
            
            if nargin < 5, C = []; 
            elseif mSB, C = round2(C, 1e-6);
            end
            
            if nargin==5
                S.mainFormula(P, T, C)
            end
        end
        
        function mainFormula(obj, P, T, C)
            obj.outData = salinityFunc(P, T, C); 
        end
        
        function delete(obj) % Destructor
            % Here in case I need it
        end
        
    end
    
end